/**
 * @file wa_task.h
 *
 */


#ifndef _WA_TASK_H
#define _WA_TASK_H

#ifdef __cplusplus
extern "C" {
#endif

/*********************
*      INCLUDES
*********************/
#include "wa_conf.h"
#include <string.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include "wa_misc.h"
#include "wa_ll.h"
/*********************
*      DEFINES
*********************/

/**********************
*      TYPEDEFS
**********************/
typedef enum
{
	WA_TASK_TYPE_TIMER,
	WA_TASK_TYPE_EVENT,
}wa_task_type;

typedef enum
{
	WA_TASK_EVENT_OR,
	WA_TASK_EVENT_AND,
}wa_task_event_type;


typedef void (*wa_task_callback)(void* task);
typedef uint32_t wa_task_event;

typedef struct 
{
	wa_task_type type;
	wa_task_callback cb;

	wa_task_event event_mask;
	wa_task_event* event;
	wa_task_event_type evnet_type;

	uint32_t period;
	uint32_t last_run_tick;
	wa_result paused;

	void* param;
}wa_task;

/**********************
* GLOBAL PROTOTYPES
**********************/
void wa_task_module_init(void);
void wa_task_handle(void);
wa_task* wa_task_create(wa_task_callback cb, wa_task_type type);
void wa_task_del(wa_task* task);
void wa_task_set_mask_evnet(wa_task* task, wa_task_event mask);
void wa_task_binding_event(wa_task* task, wa_task_event* event);
void wa_task_set_evnet_type(wa_task* task, wa_task_event_type type);
void wa_task_set_timer_period(wa_task* task, uint32_t period);
void wa_task_start_timer(wa_task* task);
void wa_task_stop_timer(wa_task* task);
wa_result wa_task_timer_is_start(wa_task* task);
void wa_task_set_param(wa_task* task, void* param);
void wa_task_event_set_bit(wa_task_event* event, wa_task_event mask);
void wa_task_event_clear_bit(wa_task_event* event, wa_task_event mask);
/**********************
*      MACROS
**********************/


#ifdef __cplusplus
} /* extern "C" */
#endif

#endif 



